package com.siecom.transport;

import static android.content.Context.POWER_SERVICE;

import static com.siecom.transport.bluetooth.BlueServer.TAG;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.PowerManager;
import android.support.annotation.RequiresApi;
import android.util.Log;

import com.siecom.hostservice.MainActivity;
import com.siecom.proto.Message;
import com.siecom.tool.LogUtil;

/**
 * Created on 2017/7/17.
 */

public class CommServer {

    protected volatile boolean isInterrupted = false;


    public void setInterrupted(boolean flag) {

        isInterrupted = flag;

    }

    public void close(){

    }

    public void sendToRemote(Message.siecomproto msg){

    }
    @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
    @SuppressLint("InvalidWakeLockTag")
    public void wakeUp() {
        PowerManager powerManager = (PowerManager) MainActivity.context.getSystemService(POWER_SERVICE);
//        LogUtil.e(TAG, "debug wakeUp: screen is on ? == " + powerManager.isInteractive());
        if (!powerManager.isInteractive()) {
            MainActivity.isWakeUp = true;
//            //屏锁管理器
//            KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
//            KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");
//            //解锁
//            kl.disableKeyguard();

            PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "cyg_wake");

            //点亮屏幕
            wakeLock.acquire(1000L);
            //释放
            wakeLock.release();
        }
    }

}
